﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.Collections;

namespace SchemaMonitor.json
{
    [DataContract]
    public class CFieldLong : CField
    {
        //Members
        [DataMember(Order = 1)]
        public List<long> Longs;

        //Constructor
        public CFieldLong(CNodeBasic parent, CTag tag, object value) : base(parent, tag)
        {
            if (value is object[])
                this.Values = (object[])value;
            else if (value is List<long>)
                this.Longs = (List<long>)value;
            else if (value is long[])
                this.Longs = new List<long>((long[])value);
            else if (value is long)
                this.Value = (long)value;
            else
                this.Value = Convert.ToInt64(value);
        }
        //Serialisation Constructors
        private CFieldLong() { }
        static CFieldLong() { ProtoBuf.Serializer.PrepareSerializer<CFieldLong>(); }

        //Must Override
        public override IList List { get { return Longs; } set { Longs = value.Cast<long>().ToList(); } }
        protected override IList InitList() { return new List<long>(); }
        protected override IList InitList(object[] array) { return array.Cast<long>().ToList(); }


    }
}
